# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Dan McGee <dan@archlinux.org>
# Contributor: Martin Striz <ms@poruba.net>

pkgname=irqbalance
pkgver=1.9.2
pkgrel=1
pkgdesc="IRQ balancing daemon for SMP systems"
arch=(x86_64)
url="https://github.com/irqbalance/irqbalance"
license=(GPL2)
backup=(etc/$pkgname.env)
depends=(glibc libnl)
makedepends=(glib2 libcap-ng ncurses numactl systemd systemd-libs)
source=($pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz)
sha512sums=('d0fb157fbfc096fa9cfb4562e51fd4c3f4fa8788f72377c58b27df67c70073b787bba05e39809dcbe17532bb5b8e74b6d27c5e5b3d9af09bc9ce1a9b6aab9378')
b2sums=('bc640323c3a594090f77983e63d9b7df177a05b859e4d29edb5b654f886c9e9f0d748ce22b1323bee443ea8369e014b9e0ce383bfe6f396692346649199d10a2')

prepare() {
  # fix location of configuration and binary in service
  sed -e 's|/path/to/|/etc/|g;s|/usr/sbin|/usr/bin|g' -i $pkgname-$pkgver/misc/$pkgname.service

  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --with-systemd
  make
}

check() {
  make -k check -C $pkgname-$pkgver
}

package() {
  depends+=(libglib-2.0.so libcap-ng.so libncursesw.so libnuma.so libsystemd.so)

  cd $pkgname-$pkgver
  make install DESTDIR="$pkgdir"
  install -vDm 644 misc/irqbalance.service -t "$pkgdir/usr/lib/systemd/system/"
  install -vDm 644 misc/irqbalance.env -t "$pkgdir/etc/"
  install -vDm 644 {AUTHORS,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
